package com.xjy.headfirst.模板方法模式;

import lombok.Data;
import lombok.ToString;

/**
 * decription:
 *
 * @author 辛纪元
 * @since 2022-07-14
 */

@Data
@ToString
public class Duck implements Comparable<Object> {
    String name;
    int weight;

    public Duck(String name, int weight) {
        this.name = name;
        this.weight = weight;
    }


    @Override
    public int compareTo(Object object) {
        Duck otherDuck = (Duck) object;
        if (this.weight < otherDuck.weight) {
            return -1;
        } else if (this.weight == otherDuck.weight) {
            return 0;
        } else {
            return 1;
        }
    }
}
